package fileIO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;

public class InputStreamReaderOutputStreamWriter {
	public static void main(String[] args) throws IOException {
		test();
		test1();
	}

	private static void test1() throws IOException, IOException {
		InputStreamReader in = new InputStreamReader(new FileInputStream(
				"/home/tarena/Desktop/7.txt"), "gbk");
		char[] buf = new char[1024];
		int n;
		while((n=in.read(buf))!=-1){
			String s = new String(buf,0,n);
			System.out.println(s);
		}
		in.close();
	}

	private static void test() throws IOException {
		OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(
				"/home/tarena/Desktop/7.txt"), "utf-8");
		out.write("a中");
		out.close();
	}
}
